package chixing.day11.work.w10;
// 折扣策略
public class DiscountStrategy implements PricingStrategy {
    private double rate; // 折扣率，如0.9表示九折

    public DiscountStrategy(double rate) {
        this.rate = rate;
    }

    @Override
    public double calculate(Product product) {
        // 原价 × 数量 × 折扣率
        return product.getPrice() * product.getQuantity() * rate;
    }

    @Override
    public String toString() {
        return rate * 10 + "折";
    }
}

